package com.isale.generator.bean;

import com.isale.generator.utils.NameUtil;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by bain.wang on 2016/1/11.
 */
public class TableInfo {
    private String name;

    private String comment;



    private List<ColumnInfo> columnInfoList = new ArrayList<ColumnInfo>();


    // =============================================================================

    /**
     * 获取类似：“CreateTime” 这样的字符串 用来拼 getter/setter 方法
     *
     * @return
     */
    public String getBigJavaName() {
        return NameUtil.getBigJavaName(name);
    }

    /**
     * 获取类似：“createTime” 这样的字符串  用来搞定java变量名称
     *
     * @return
     */
    public String getJavaName() {
        return NameUtil.getJavaName(name);
    }


    public List<ColumnInfo> getColumnInfoListForOutput() {
        List<ColumnInfo> columnInfoList2 = new ArrayList<ColumnInfo>();

        for (ColumnInfo tmp : columnInfoList) {
            if (StringUtils.equals(tmp.getField(), "id")
                    || StringUtils.equals(tmp.getField(), "create_time")
                    || StringUtils.equals(tmp.getField(), "update_time")) {
                continue;
            }

            columnInfoList2.add(tmp);
        }

        return columnInfoList2;
    }

    // ========================================================================================================================================



    public List<ColumnInfo> getColumnInfoList() {
        return columnInfoList;
    }

    public void setColumnInfoList(List<ColumnInfo> columnInfoList) {
        this.columnInfoList = columnInfoList;
    }

    /**
     *
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}
